{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "平均温度是: 49.07277585787492\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "# 读取Excel文件\n",
    "file_path = \"2023-09-13.xlsx\"\n",
    "df = pd.read_excel(file_path)\n",
    "\n",
    "# 假设温度列的名称是'Temperature'\n",
    "# 计算温度的平均值\n",
    "average_temperature = df['温度'].mean()\n",
    "\n",
    "# 显示平均值\n",
    "print(\"平均温度是:\", average_temperature)\n",
    "\n",
    "# 将平均值写入Excel文件的第30行\n",
    "df.loc[29, '温度'] = average_temperature  # 注意：索引从0开始，所以第30行的索引是29\n",
    "\n",
    "# 将DataFrame写回到Excel文件\n",
    "df.to_excel(file_path, index=False)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
